<h2><?php pc_echo(pc_message("order.overview.title")); ?></h2>
<?php $order = pc_variable("commerce.order"); ?>
<form method="post" action="dispatcher.php">
    <fieldset class="distinct">
        <legend><?php pc_echo(pc_message("order.title")); ?></legend>
        <table class="order">
            <thead>
                <tr>
                    <th><?php pc_echo(pc_message("order.quantity")); ?></th>
                    <th class="description"><?php pc_echo(pc_message("order.article")); ?></th>
                    <th><?php pc_echo(pc_message("order.price")); ?></th>
                    <th><?php pc_echo(pc_message("order.value")); ?></th>
                </tr>
            </thead>
            <tbody>
                <?php
                foreach($order->get("orderItems") as $index => $orderItem) { 
                    pc_pagelet("order/overview/item",
                            array(
                                "commerce.orderItem" => $orderItem
                            ));
                } ?>
                <tr class="total">
                    <td><?php pc_echo($order->getTotalQuantity()); ?></td>
                    <td colspan="2"><strong><?php pc_echo(pc_message("order.total")); ?></strong></td>
                    <td class="money"><?php pc_echo($order->getCurrency()->getSymbol() . " " . pc_format_number($order->getTotalAmount(), "0.00")); ?></td>
                </tr>
            </tbody>
        </table>
        <span><a href="dispatcher.php?controller=Commerce/ShowOrder&amp;targetPage.location=<?php pc_echo(pc_encode_url(pc_variable("currentPage.location")))?>" class="edit"><?php pc_echo(pc_message("common.edit")); ?></a></span>
    </fieldset>
    <fieldset class="distinct">
        <legend><?php pc_echo(pc_message("order.billing")); ?></legend>
        <span>
            <label><?php pc_echo(pc_message("field.name")); ?></label>
            <?php pc_echo($order->get("billingName")); ?>
        </span>
        <span>
            <label><?php pc_echo(pc_message("field.address.line1")); ?></label>
            <?php pc_echo($order->get("billingAddress")->get("line1")); ?>
        </span>
        <span>
            <label><?php pc_echo(pc_message("field.address.line2")); ?></label>
            <?php pc_echo($order->get("billingAddress")->get("line2")); ?>
        </span>
        <span>
            <label><?php pc_echo(pc_message("field.address.postalCode")); ?></label>
            <?php pc_echo($order->get("billingAddress")->get("postalCode")); ?>
        </span>
        <span>
            <label><?php pc_echo(pc_message("field.address.city")); ?></label>
            <?php pc_echo($order->get("billingAddress")->get("city")); ?>
        </span>
        <span>
            <label><?php pc_echo(pc_message("field.emailAddress")); ?></label>
            <?php pc_echo($order->get("billingEmailAddress")); ?>
        </span>
        <span>
            <label><?php pc_echo(pc_message("field.vatCode")); ?></label>
            <?php pc_echo($order->get("vatCode")); ?>
        </span>
        <span>
            <label><?php pc_echo(pc_message("field.paymentMethod")); ?></label>
            <?php $paymentMethod = $order->get("paymentMethod");
            if($paymentMethod == Pageley_Commerce_Domain_PaymentMethod::$CASH) {
                pc_echo(pc_message("order.paymentMethod.cash"));
            } else if($paymentMethod == Pageley_Commerce_Domain_PaymentMethod::$TRANSFER) {
                pc_echo(pc_message("order.paymentMethod.transfer"));
            } else if($paymentMethod == Pageley_Commerce_Domain_PaymentMethod::$ELECTRONIC) {
                pc_echo(pc_message("order.paymentMethod.electronic"));
            } else if($paymentMethod == Pageley_Commerce_Domain_PaymentMethod::$CREDIT_CARD) {
                pc_echo(pc_message("order.paymentMethod.creditCard"));
            } ?>
        </span>
        <span>
            <?php $sendInvoice = $order->get("sendInvoice");
            if($sendInvoice) {
                pc_echo(pc_message("order.sendInvoice.yes"));
            } else {
                pc_echo(pc_message("order.sendInvoice.no"));
            }?>
        </span>
        <span><a href="dispatcher.php?controller=Commerce/Authenticated/CheckOut&amp;targetPage.location=<?php pc_echo(pc_encode_url(pc_variable("currentPage.location")))?>" class="edit"><?php pc_echo(pc_message("common.edit")); ?></a></span>
    </fieldset>
    <fieldset class="distinct">
        <legend><?php pc_echo(pc_message("order.delivery")); ?></legend>
        <span>
            <label><?php pc_echo(pc_message("field.name")); ?></label>
            <?php pc_echo($order->get("deliveryName")); ?>
        </span>
        <span>
            <label><?php pc_echo(pc_message("field.address.line1")); ?></label>
            <?php pc_echo($order->get("deliveryAddress")->get("line1")); ?>
        </span>
        <span>
            <label><?php pc_echo(pc_message("field.address.line2")); ?></label>
            <?php pc_echo($order->get("deliveryAddress")->get("line2")); ?>
        </span>
        <span>
            <label><?php pc_echo(pc_message("field.address.postalCode")); ?></label>
            <?php pc_echo($order->get("deliveryAddress")->get("postalCode")); ?>
        </span>
        <span>
            <label><?php pc_echo(pc_message("field.address.city")); ?></label>
            <?php pc_echo($order->get("deliveryAddress")->get("city")); ?>
        </span>
        <span>
            <label><?php pc_echo(pc_message("field.comment")); ?></label>
            <?php pc_echo($order->get("comment")); ?>
        </span>
        <span><a href="dispatcher.php?controller=Commerce/Authenticated/CheckOut&amp;targetPage.location=<?php pc_echo(pc_encode_url(pc_variable("currentPage.location")))?>" class="edit"><?php pc_echo(pc_message("common.edit")); ?></a></span>
    </fieldset>
    <div class="buttons">
        <input type="hidden" name="referringPage.location" value="<?php pc_echo(pc_variable("currentPage.location")); ?>"/>
        <input type="hidden" name="referringPage.name" value="<?php pc_echo(pc_message("order.title")); ?>"/>
        <input type="hidden" name="targetPage.location" value="<?php pc_echo(pc_variable("targetPage.location")); ?>"/>
        <button type="submit" name="controller" value="Commerce/Authenticated/PlaceOrder" class="confirm"><?php pc_echo(pc_message("order.overview.submit")); ?></button>
    </div>
</form>